import React from 'react'
import ExportJsonExcel from 'js-export-excel'
import { Button } from 'antd'

const ExportExcel = () => {
  const ExportToExcel = () => {
    // 准备的数据
    let option = {}
    option.fileName = 'order infomation' // 导出的Excel文件名
    option.datas = [
      {
        sheetData: [
          {
            name: '侯德康1',
            age: 101,
          },
        ],
        sheetName: 'sheet1',
        sheetHeader: ['name', 'age'],
      },
      {
        sheetData: [
          {
            name: '侯德康2',
            age: 102,
          },
        ],
        sheetName: 'sheet2',
        sheetHeader: ['name', 'age'],
      },
    ]

    const toExcel = new ExportJsonExcel(option)
    toExcel.saveExcel()
  }

  return (
    <div>
      <Button onClick={() => ExportToExcel()}>Export to Excel</Button>
    </div>
  )
}

export default ExportExcel
